import java.util.Arrays;

public class TextDemo {
    public static int[] generateRandomArray(int maxSize,int maxValue){
        int[] arr = new int[(int)((maxSize+1)*Math.random())];
        for(int i = 0;i<arr.length;i++){
            arr[i] = (int)((maxValue+1)*Math.random())-(int)(maxValue*Math.random());
        }
        return arr;
    }

    public static int[] copyArray(int[] arr){
        if(arr==null){
            return null;
        }
        int[] res = new int[arr.length];
        for(int i = 0;i<arr.length;i++){
            res[i] = arr[i];
        }
        return res;
    }

    public static void bubbleSort(int[] arr){
        boolean t = false;
        for(int i = 0;i<arr.length;i++){
            t = false;
            for(int j = 0;j<arr.length-1-i;j++){
                if(arr[j]>arr[j+1]){
                    int tem = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tem;
                    t = true;
                }
            }
            if(!t){
                break;
            }
        }
    }

    public static void comparator(int[] arr){
        Arrays.sort(arr);
    }

    public static boolean isEqual(int[] arr1,int[] arr2){
        if((arr1==null&&arr2!=null)||(arr1!=null&&arr2==null)){
            return false;
        }
        if(arr1==null&&arr2==null){
            return true;
        }
        if(arr1.length!=arr2.length){
            return false;
        }
        for(int i = 0;i<arr1.length;i++){
            if(arr1[i]!=arr2[i]){
                return false;
            }
        }
        return true;
    }

    public static void printArray(int[] arr){
        if(arr==null){
            return;
        }
        for(int i = 0;i<arr.length;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.println();
    }

    public static void main(String[] args) {
      int maxSize = 100;
      int textTime = 500000;
      int maxValue = 100;
      boolean succeed = true;
      for(int i = 0;i<textTime;i++){
          int[] arr1 = generateRandomArray(maxSize,maxValue);
          int[] arr2 = copyArray(arr1);
          bubbleSort(arr1);
          comparator(arr2);
          if(!isEqual(arr1,arr2)){
            succeed = false;
            break;
          }
      }
        System.out.println(succeed?"Nice":"Fucking fucked!");
      int[] arr = generateRandomArray(maxSize,maxValue);
      printArray(arr);
      bubbleSort(arr);
      printArray(arr);
    }
}

